function DateTimeOperators(){
	this.add = "+";
	this.sub = "-";
	this.mul = "*";
	this.div = "/";
	
	return this;
}

function DateTimeTypes(){
	this.year = "year";
	this.month = "month";
	this.day = "day";
	
	this.hours = "hours";
	this.minutes = "minutes";
	this.seconds = "seconds";
	
	return this;	
	
}

function DateTime(timeOnly){
	this.year = 0;
	this.month = 0;
	this.day = 0;
	
	this.hours = 0;
	this.minutes = 0;
	this.seconds = 0;
	
	this.timeOnly = true;
	
	if (arguments.length>0){
		this.timeOnly = arguments[0];
	}
	
	return this;
}

DateTime.prototype.setTime = function(time){
	var timeParts = time.split(":");
		
	
	if (timeParts.length==2){
		this.hours = parseInt(timeParts[0]);
		this.minutes = parseInt(timeParts[1]);
		this.seconds = 0;
	}else{
		this.hours = parseInt(timeParts[0]);
		this.minutes = parseInt(timeParts[1]);
		this.seconds = parseInt(timeParts[2]);
	}
}

DateTime.prototype.inSeconds = function(){
	var seconds = 0;
	
	seconds = (this.year * 12 * 30 * 86400) + 
						(this.month * 30 * 86400) + 
						(this.day * 86400) +
						(this.hours * 3600) +
						(this.minutes * 60) +
						this.seconds;
	return seconds;
	 
}//inSeconds

DateTime.prototype.fromSeconds = function(seconds){
	this.year = 0;
	this.month = 0;
	this.day = 0;
	
	this.hours = 0;
	this.minutes = 0;
	this.seconds = 0;
	
	this.seconds = seconds;
	
	if (this.seconds >= 60){
		var minutes = this.seconds / 60;
		
		if (minutes >=60){
			this.hours = parseInt(parseInt(minutes) / 60);
			this.minutes = parseInt(minutes % 60);
		}else{
			this.minutes = parseInt(minutes);
		}
		
		this.seconds = this.seconds % 60;
	}
}

DateTime.prototype.operate = function(operator, type, value){
	// *, minutes, 10 ==> this.mintues = this.mintues * 10;
	
	//alert("this." + type + " = " + "this." + type + " " + operator + " " + value);
	
	var dt = new DateTime();
	switch (type){
		case new DateTimeTypes().hours:
			dt.setTime(value + ":00:00");
		break;
		case new DateTimeTypes().minutes:
			dt.setTime("00:" + value + ":00");
		break;
		case new DateTimeTypes().seconds:
			dt.setTime("00:00:" + value);
		break;
	}
	
	var dtSecs = dt.inSeconds();
	var thisSecs = this.inSeconds();
	
	eval("thisSecs = thisSecs" + " " + operator + " " + "dtSecs");
	
	this.fromSeconds(thisSecs);
}

DateTime.prototype.operate2 = function(operator, dateTime){
	var dtSecs = dateTime.inSeconds();
	var thisSecs = this.inSeconds();
	
	eval("thisSecs = thisSecs" + " " + operator + " " + "dtSecs");
	
	this.fromSeconds(thisSecs);	
	this.seconds = parseInt(this.seconds);
}

DateTime.prototype.toString = function(){
	if (this.timeOnly){
		return this.hours + ":" + this.minutes + ":" + this.seconds;
	}
	
	return this.day + "/" + this.month + "/" + this.year + " " + this.hours + ":" + this.minutes + ":" + this.seconds;
}